/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) radix(10) lradix(10) 

package com.kingdee.signup;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.GeoPoint;
import com.baidu.mapapi.ItemizedOverlay;
import com.baidu.mapapi.MKAddrInfo;
import com.baidu.mapapi.MKDrivingRouteResult;
import com.baidu.mapapi.MKGeneralListener;
import com.baidu.mapapi.MKPoiInfo;
import com.baidu.mapapi.MKPoiResult;
import com.baidu.mapapi.MKSearch;
import com.baidu.mapapi.MKSearchListener;
import com.baidu.mapapi.MKTransitRouteResult;
import com.baidu.mapapi.MKWalkingRouteResult;
import com.baidu.mapapi.MapActivity;
import com.baidu.mapapi.MapController;
import com.baidu.mapapi.MapView;
import com.baidu.mapapi.OverlayItem;
import com.kingdee.signup.PoiSearchActivity.MySearchListener;
import com.kingdee.signup.model.SearchData;
import com.kingdee.signup.utils.CommonUtils;
import com.kingdee.signup.utils.ComparatorDistance;
import com.kingdee.signup.utils.NLog;
import com.kingdee.signup.utils.StringUtils;

public class MapShowActivity extends MapActivity implements
		android.view.View.OnClickListener {
	public class MyOverLayItem extends ItemizedOverlay {

		protected OverlayItem createItem(int i) {
			return (OverlayItem) list.get(i);
		}

		protected boolean onTap(int i) {
			com.baidu.mapapi.MapView.LayoutParams layoutparams = (com.baidu.mapapi.MapView.LayoutParams) mPopView
					.getLayoutParams();
			layoutparams.point = new GeoPoint((int) (1000000D * mLatitude),
					(int) (1000000D * mLongitude));
			mapView.updateViewLayout(mPopView, layoutparams);
			mPopView.setVisibility(0);
			TextView textview = (TextView) findViewById(2131493030);
			textview.setTextColor(Color.parseColor("#000000"));
			textview.setText(mPlace);
			return true;
		}

		public boolean onTap(GeoPoint geopoint, MapView mapview) {
			mPopView.setVisibility(0);
			//将单击的经纬度值保存
			CommonUtils.addConfigInfo(mContext, "Lat", String.valueOf(geopoint.getLatitudeE6()));
			CommonUtils.addConfigInfo(mContext, "Lon",String.valueOf(geopoint.getLongitudeE6()));
//			geopoint=new GeoPoint(39904965, 116327764);
//			try{
//				mksearch.reverseGeocode(geopoint);
//			}catch(Exception e){
//				NLog.d("debug",e.toString());
//			}
			//提示信息
			Toast.makeText(mContext,"lat:"+geopoint.getLatitudeE6()+" Lon:"+geopoint.getLongitudeE6(),1).show();
			return super.onTap(geopoint, mapview);
		}

		public int size() {
			return list.size();
		}

		private List list;
		final MapShowActivity this$0;

		public MyOverLayItem(Drawable drawable) {
			super(drawable);
			this$0 = MapShowActivity.this;
			list = new ArrayList();
			NLog.d("tt",
					(new StringBuilder("-@@@@@@@--mLatitude----"))
							.append(mLatitude).append("---mLongitude--")
							.append(mLongitude).toString());
			GeoPoint geopoint = new GeoPoint((int) (1000000D * mLatitude),
					(int) (1000000D * mLongitude));
			list.add(new OverlayItem(geopoint, "point1", "point1"));
			populate();
		}
	}

	public MapShowActivity() {
		mMapView = null;
		mSearch = null;
		KeyString = "285B415EBAB2A92293E85502150ADA7F03C777C4";
	}

	private void initPopview() {
		mPopView = super.getLayoutInflater().inflate(2130903070, null);
		mapView.addView(mPopView, new com.baidu.mapapi.MapView.LayoutParams(-2,
				-2, null, 81));
		mPopView.setVisibility(8);
	}

	protected boolean isRouteDisplayed() {
		return false;
	}

	public void onClick(View view)
    {
	    switch (view.getId())
	    {
		    case 2131493094:
		        finish();
		    default:    
	    }
    }

	public class MySearchListener implements MKSearchListener {
		public void onGetAddrResult(MKAddrInfo mkaddrinfo, int i) {
			if (mkaddrinfo == null){
				CommonUtils.addConfigInfo(mContext, "MyAdd","361");
			}
			else{
				CommonUtils.addConfigInfo(mContext, "MyAdd",mkaddrinfo.strAddr);
				//提示信息
				Toast.makeText(mContext,"Myadd:"+mkaddrinfo.strAddr,2).show();
			}
		}

		public void onGetDrivingRouteResult(
				MKDrivingRouteResult mkdrivingrouteresult, int i) {
		}

		public void onGetPoiResult(MKPoiResult mkpoiresult, int x, int y)
        {
        }

		public void onGetTransitRouteResult(
				MKTransitRouteResult mktransitrouteresult, int i) {
		}

		public void onGetWalkingRouteResult(
				MKWalkingRouteResult mkwalkingrouteresult, int i) {
		}

		final MapShowActivity this$0;

		public MySearchListener() {
			super();
			this$0 = MapShowActivity.this;
		}
		
	}
	
	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		setContentView(2130903086);
		mContext = this;
		mBack = (ImageView) findViewById(2131493094);
		mBack.setOnClickListener(this);
		mAddress = (TextView) findViewById(2131493097);
		mapView = (MapView) findViewById(2131493096);
		String s = getIntent().getStringExtra("lat");
		String s1 = getIntent().getStringExtra("lon");
		mPlace = getIntent().getStringExtra("address");
		mLatitude = Double.parseDouble(s);
		mLongitude = Double.parseDouble(s1);
		NLog.d("tt", (new StringBuilder("----mLatitude----")).append(mLatitude)
				.append("---mLongitude--").append(mLongitude).toString());
		mAddress.setText(mPlace);
		bMapManager = new BMapManager(this);
		bMapManager.init(KeyString, new MKGeneralListener() {

			public void onGetNetworkState(int i) {
			}

			public void onGetPermissionState(int i) {
				if (i == 300)
					Toast.makeText(
							MapShowActivity.this,
							"\u8F93\u5165\u7684key\u6709\u9519\uFF0C\u8BF7\u6838\u5B9E\uFF01\uFF01",
							1).show();
			}

			final MapShowActivity this$0;
			{
				//super();
				this$0 = MapShowActivity.this;
				
			}
		});
		bMapManager.start();
		initMapActivity(bMapManager);
		initPopview();
		mapView.setBuiltInZoomControls(true);
		mapController = mapView.getController();
		GeoPoint geopoint = new GeoPoint((int) (1000000D * mLatitude),
				(int) (1000000D * mLongitude));
		mapController.setCenter(geopoint);
		mapController.setZoom(16);
		Drawable drawable = getResources().getDrawable(2130837561);
		mapView.getOverlays().add(new MyOverLayItem(drawable));
		//设置搜索
//		mksearch = new MKSearch();
//		mksearch.init(mapManager, new MySearchListener());
	}

	protected void onDestroy() {
		if (bMapManager != null) {
			bMapManager.destroy();
			bMapManager = null;
		}
		super.onDestroy();
	}

	protected void onPause() {
		if (bMapManager != null)
			bMapManager.stop();
		super.onPause();
	}

	protected void onResume() {
		if (bMapManager != null)
			bMapManager.start();
		super.onResume();
	}
	private MKSearch mksearch;
	private String KeyString;
	private BMapManager bMapManager;
	GeoPoint geoPoint;
	private TextView mAddress;
	private ImageView mBack;
	private Context mContext;
	private double mLatitude;
	private double mLongitude;
	MapView mMapView;
	private String mPlace;
	public View mPopView;
	MKSearch mSearch;
	private MapController mapController;
	private BMapManager mapManager;
	private MapView mapView;

}